﻿@model System.Web.Security.MembershipUserCollection

@{
    ViewBag.Title = ViewData["SiteName"] + " - " + ViewData["PageTitle"];
    Layout = "~/RazorThemes/Default/Views/Shared/_Layout.cshtml";
}
@section HtmlHead{
    <link rel="stylesheet" type="text/css" href="/scripts/flexigrid/css/flexigrid/flexigrid.css" />
    <style type="text/css">
        .searchbox
        {
            background-position: center top;
            background: transparent url(/scripts/flexigrid/css/flexigrid/images/wbg.gif) repeat-x scroll center top;
            border-color: -moz-use-text-color #CCCCCC;
            border-style: none solid;
            border-width: 0 0px 0 0px;
            display: block;
            font-weight: bold;
            overflow: hidden;
            position: relative;
            white-space: nowrap;
            float: right;
            margin-left:10px;
            padding-left:10px;
            margin-top: -29px;
        }
        .gridClear
        {
        	height:20px;
        	width:40px;
        	font-size:x-small;
        	padding-bottom:16px;
        }
    </style>
}

<div class="contentpage-outerdiv">
    @Html.ValidationSummary() 
    <div class="field-validation-error">
        @ViewData["Message"].ToString()</div>
    <h2>
        Account Management</h2>
    <p>
        <b>Users Online Now: </b>
        @ViewData["UsersOnlineNow"] </p>
    <div>
        <!--modified line 1191-1219 of flexigrid.js to load the search box up here-->
        <div id="gridSearchBox" class="searchbox">
        </div>
        <table id="payments" style="display: none">
        </table>
    </div>
</div> 
@section ScriptContent{
    <script src="@Url.Content("/Scripts/flexigrid/flexigrid.js")" type="text/javascript"></script>
    <script type="text/javascript">
        function DoSearch() {
            var queryToSend = $('input[name=q]', g.sDiv).val();
            var qtypeToSend = $('select[name=qtype]', g.sDiv).val();
            var data = {
                query: phrase,
                qtype: qtypeToSend
            }
            //var encoded = JSON.stringify(data);
            $.post("/backofficeAjax/GetUsers",
	            { query: phrase, qtype: qtypeToSend },
	            function (data) {
	                var objdata = data;
	                if (objdata.error) {
	                    //alert(objdata.error);
	                }
	                else {
	                    $("#FlexTable").flexAddData(data);
	                }
	            },
	            "json"
            );
        }

        $("#payments").flexigrid({
            url: '/backofficeAjax/GetUsers',
            dataType: 'json',
            colModel: [
                { display: 'Edit', name: 'Edit', width: 60, sortable: false, align: 'left' },
				{ display: 'User Name', name: 'UserName', width: 120, sortable: true, align: 'left' },
				{ display: 'E-Mail', name: 'Email', width: 120, sortable: true, align: 'left' },
				{ display: 'Creation Date', name: 'CreationDate', width: 150, sortable: true, align: 'left' },
				{ display: 'Last Used', name: 'LastActivityDate', width: 70, sortable: true, align: 'left' },
				{ display: 'Approved', name: 'IsApproved', width: 80, sortable: true, align: 'left' }
				],
            searchitems: [
				{ display: 'UserName', name: 'UserName', isdefault: true },
				{ display: 'EMail', name: 'Email' },
				{ display: 'Created', name: 'CreationDate' },
				{ display: 'Last Used', name: 'LastActivityDate' },
				{ display: 'Approved', name: 'IsApproved' }
				],
            sortname: 'LastActivityDate',
            sortorder: 'desc',
            usepager: true,
            title: 'Users',
            useRp: true,
            nowrap: false,
            rp: 25,
            showTableToggleBtn: false,
            width: 710,
            height: 415,
            resizable: false,
            rpOptions: [25, 50, 75, 95],
            showToggleBtn: false,
            onSuccess: SetOptions
        });

        function Delete(username) {
            var doit = confirm("are you sure you want to delete user " + username + "?");
            if (doit) {
                window.location.href = "/Account/ManageUsers/" + username;
            }
        }
        function SetOptions() {

        }

        // $('input[name=q],select[name=qtype]', g.sDiv).keydown(function(e) { if (e.keyCode == 13) g.doSearch() });
    </script>
}
</asp:Content>
